package com.beiing.tianshuai.tianshuai.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.CodeBean;
import com.beiing.tianshuai.tianshuai.entity.UploadImgBean;
import com.beiing.tianshuai.tianshuai.model.DiscoveryPublishModel;
import com.beiing.tianshuai.tianshuai.model.DiscoveryPublishModelImpl;
import com.beiing.tianshuai.tianshuai.view.DiscoveryPublishViewImpl;

import java.io.File;
import java.util.List;

/**
 * Created by Jinni on 2017/11/7 0007
 */

public class DiscoveryPublishPresenter extends BasePresenter implements DiscoveryPublishPresenterImpl, DiscoveryPublishModel.OnResponseListener{

    private DiscoveryPublishViewImpl mView;
    private DiscoveryPublishModelImpl mModel;

    public DiscoveryPublishPresenter(DiscoveryPublishViewImpl view) {
        mView = view;
        mModel = new DiscoveryPublishModel(this);
    }

    @Override
    public void UploadImages(List<File> images) {
        mView.showProgress();
        mModel.UploadImages(images);
    }

    @Override
    public void getPublishResult(String content, String uid, String title, String freshCover) {
        mView.showProgress();
        mModel.getPublishResult(content, uid, title, freshCover);
    }

    @Override
    public void onSuccess(CodeBean bean) {
        mView.hideProgress();
        mView.publishSuccess(bean);
    }

    @Override
    public void onUploadSuccess(UploadImgBean bean) {
        mView.hideProgress();
        mView.onRequestSuccess(bean);
    }

    @Override
    public void onError(Throwable throwable) {
        mView.hideProgress();
        mView.onRequestFailed(throwable);
    }
}
